import React, { useEffect } from 'react';
import { connect } from 'umi';
import { ConnectProps, ConnectState, UserModelState } from '@/models/connect';
import Header from './Header';
import MyList from './MyList';
import Logout from './Logout';

interface UserPagePropsType extends ConnectProps {
  user: UserModelState;
}
const UserPage: React.FC<UserPagePropsType> = ({ dispatch, user }) => {
  useEffect(() => {
    dispatch({
      type: 'user/queryDetail',
    });
  }, []);
  const { name, icon } = user.currentUser;
  console.log(user, '****999');
  const logout = () => {
    // dispatch
    dispatch({
      type: 'user/fetchLogout',
    });
  };
  return (
    <div>
      <Header name={name} icon={icon} />
      <MyList />
      <Logout logout={logout} />
    </div>
  );
};
export default connect(({ user }: ConnectState) => ({ user }))(UserPage);
